/*
    This is a set of libraries to assist in OpenGl and Other Applications
    Copyright (C) 2008  The Modular Engine Team

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
#define HUDMODULE
#include "HUDCheckbox.h"

namespace ModularEngine
{
	HUDCheckbox::HUDCheckbox()
	{
		LOADCOLORS;
		mbChecked = false;
	}

	HUDCheckbox::~HUDCheckbox()
	{
		// Not much to deinitialize
	}

	int HUDCheckbox::initialize()
	{
		// Load the check texture
		ModularEngine::OpenglModule::getSingleton().loadTexture( "check.tga" );
		// until I implement drawImage w/ custom dims
		mvDimensions = Vector2d( 13, 13 );
		return 1;
	}

	void HUDCheckbox::draw()
	{
		// Reset everything
		gl->resetCoords();

		glColor3f( mvBaseColor.x, mvBaseColor.y, mvBaseColor.z );
		gl->drawRect( mvPosition - Vector2d( 1, 1 ), mvDimensions + Vector2d( 2, 2 ) );

		// Draw surrounding box.
		gl->drawGradientRect( mvPosition, mvDimensions, mvBaseColor, mvBaseColor*.6 );

		// if it's checked, draw the check
		if( mbChecked )
			gl->drawImage( "check.tga", mvPosition+Vector2d( 1, 1 ) );		

	}

	void HUDCheckbox::mouseInput(ModularEngine::Vector2d vPos, UINT nDown)
	{
		// Switch the checkmark when clicked
		mbChecked = !mbChecked;
	}

	void HUDCheckbox::keyboardInput(UINT nKey)
	{
		// Do Nothing
	}

	bool HUDCheckbox::isChecked()
	{
		// Return checkmark state
		return mbChecked;
	}

	void HUDCheckbox::setCheck( bool bCheck )
	{
		// Set the checkmark
		mbChecked = bCheck;
	}



}
